<template>
  <div class="user-avator-dropdown">
    <Dropdown @on-click="handleClick">
      <Avatar :src="userAvator" style="margin-right: 5px;"/>
      <Icon :size="22" color="#999" type="md-arrow-dropdown"></Icon>
      <DropdownMenu slot="list">
        <DropdownItem name="logout" style="display: flex;justify-content: center;align-items: center;" >
          <img src="../../../../assets/images/exit.png" alt="" width="18"/>
          <span style="color:#333;font-size: 14px;padding-left: 10px;">退出登录</span>
        </DropdownItem>
      </DropdownMenu>
    </Dropdown>
  </div>
</template>

<script>
import './user.less'
import { mapActions } from 'vuex'
export default {
	name: 'User',
	props: {
		userAvator: {
			type: String,
			default: '',
		},
	},
	methods: {
		...mapActions(['handleLogOut']),
		handleClick(name) {
			switch (name) {
				case 'logout':
					this.handleLogOut().then(() => {
						this.$router.push({
							name: 'login',
						})
					})
					break;
                case 'change':
                    window.location.href = '/admin-view/exhibition_list';
                    break;
			}
		},
	},
}
</script>
